// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot;

public sealed partial class ReadOnlyUrlRepositorySettings
{
	[JsonInclude, JsonPropertyName("chunk_size")]
	public Elastic.Clients.Elasticsearch.Serverless.ByteSize? ChunkSize { get; set; }
	[JsonInclude, JsonPropertyName("compress")]
	public bool? Compress { get; set; }
	[JsonInclude, JsonPropertyName("http_max_retries")]
	public int? HttpMaxRetries { get; set; }
	[JsonInclude, JsonPropertyName("http_socket_timeout")]
	public Elastic.Clients.Elasticsearch.Serverless.Duration? HttpSocketTimeout { get; set; }
	[JsonInclude, JsonPropertyName("max_number_of_snapshots")]
	public int? MaxNumberOfSnapshots { get; set; }
	[JsonInclude, JsonPropertyName("max_restore_bytes_per_sec")]
	public Elastic.Clients.Elasticsearch.Serverless.ByteSize? MaxRestoreBytesPerSec { get; set; }
	[JsonInclude, JsonPropertyName("max_snapshot_bytes_per_sec")]
	public Elastic.Clients.Elasticsearch.Serverless.ByteSize? MaxSnapshotBytesPerSec { get; set; }
	[JsonInclude, JsonPropertyName("url")]
	public string Url { get; set; }
}

public sealed partial class ReadOnlyUrlRepositorySettingsDescriptor : SerializableDescriptor<ReadOnlyUrlRepositorySettingsDescriptor>
{
	internal ReadOnlyUrlRepositorySettingsDescriptor(Action<ReadOnlyUrlRepositorySettingsDescriptor> configure) => configure.Invoke(this);

	public ReadOnlyUrlRepositorySettingsDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Serverless.ByteSize? ChunkSizeValue { get; set; }
	private bool? CompressValue { get; set; }
	private int? HttpMaxRetriesValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Duration? HttpSocketTimeoutValue { get; set; }
	private int? MaxNumberOfSnapshotsValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.ByteSize? MaxRestoreBytesPerSecValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.ByteSize? MaxSnapshotBytesPerSecValue { get; set; }
	private string UrlValue { get; set; }

	public ReadOnlyUrlRepositorySettingsDescriptor ChunkSize(Elastic.Clients.Elasticsearch.Serverless.ByteSize? chunkSize)
	{
		ChunkSizeValue = chunkSize;
		return Self;
	}

	public ReadOnlyUrlRepositorySettingsDescriptor Compress(bool? compress = true)
	{
		CompressValue = compress;
		return Self;
	}

	public ReadOnlyUrlRepositorySettingsDescriptor HttpMaxRetries(int? httpMaxRetries)
	{
		HttpMaxRetriesValue = httpMaxRetries;
		return Self;
	}

	public ReadOnlyUrlRepositorySettingsDescriptor HttpSocketTimeout(Elastic.Clients.Elasticsearch.Serverless.Duration? httpSocketTimeout)
	{
		HttpSocketTimeoutValue = httpSocketTimeout;
		return Self;
	}

	public ReadOnlyUrlRepositorySettingsDescriptor MaxNumberOfSnapshots(int? maxNumberOfSnapshots)
	{
		MaxNumberOfSnapshotsValue = maxNumberOfSnapshots;
		return Self;
	}

	public ReadOnlyUrlRepositorySettingsDescriptor MaxRestoreBytesPerSec(Elastic.Clients.Elasticsearch.Serverless.ByteSize? maxRestoreBytesPerSec)
	{
		MaxRestoreBytesPerSecValue = maxRestoreBytesPerSec;
		return Self;
	}

	public ReadOnlyUrlRepositorySettingsDescriptor MaxSnapshotBytesPerSec(Elastic.Clients.Elasticsearch.Serverless.ByteSize? maxSnapshotBytesPerSec)
	{
		MaxSnapshotBytesPerSecValue = maxSnapshotBytesPerSec;
		return Self;
	}

	public ReadOnlyUrlRepositorySettingsDescriptor Url(string url)
	{
		UrlValue = url;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (ChunkSizeValue is not null)
		{
			writer.WritePropertyName("chunk_size");
			JsonSerializer.Serialize(writer, ChunkSizeValue, options);
		}

		if (CompressValue.HasValue)
		{
			writer.WritePropertyName("compress");
			writer.WriteBooleanValue(CompressValue.Value);
		}

		if (HttpMaxRetriesValue.HasValue)
		{
			writer.WritePropertyName("http_max_retries");
			writer.WriteNumberValue(HttpMaxRetriesValue.Value);
		}

		if (HttpSocketTimeoutValue is not null)
		{
			writer.WritePropertyName("http_socket_timeout");
			JsonSerializer.Serialize(writer, HttpSocketTimeoutValue, options);
		}

		if (MaxNumberOfSnapshotsValue.HasValue)
		{
			writer.WritePropertyName("max_number_of_snapshots");
			writer.WriteNumberValue(MaxNumberOfSnapshotsValue.Value);
		}

		if (MaxRestoreBytesPerSecValue is not null)
		{
			writer.WritePropertyName("max_restore_bytes_per_sec");
			JsonSerializer.Serialize(writer, MaxRestoreBytesPerSecValue, options);
		}

		if (MaxSnapshotBytesPerSecValue is not null)
		{
			writer.WritePropertyName("max_snapshot_bytes_per_sec");
			JsonSerializer.Serialize(writer, MaxSnapshotBytesPerSecValue, options);
		}

		writer.WritePropertyName("url");
		writer.WriteStringValue(UrlValue);
		writer.WriteEndObject();
	}
}